/*2xfYlvBzgNfctrVamd18oLATkukPltP/lqqKWCwDAvihRtHNmksWzOZslYhN6jqs*/
/*************************
 * 工程转固
 ************************/

import { proTransferPageCode, proAppcode, proTransferSearch, proTransferHead } from '../constants';
import { linkCard } from './buttonClick';
import {ReferConfig} from './transassetConst';
import fa from 'fa';
const { fa_components: { ReferFilter: { addSearchAreaReferFilter } } } = fa;

export default function(props) {
    let that = this
	props.createUIDom(
		{
			pagecode: proTransferPageCode,
			appcode: proAppcode
		},
		(data) => {
			if (data) {
				if (data.template) {
					let meta = data.template;
					meta = modifierMeta.call(this, props, meta);
                    props.meta.addMeta(meta);
                    that.updateDataFn();
				}
			}
		}
	);
}
function modifierMeta(props, meta) {
	let referConfig = {
		searchId: proTransferSearch,
		specialFields: ReferConfig.specialFields,
	};

	// 查询条件过滤
	addSearchAreaReferFilter.call(this, props, meta, referConfig);
	let transi_type= 'HJ-01';
	// 查询条件特殊处理
	meta[proTransferSearch].items.map((item) => {
		//按交易类型不同过滤不同的建卡方式
		if (item.attrcode === 'create_card_style') {
			let newoptions = [];
			if (transi_type === 'HJ-02') {
				item.options.map((option) => {
					if (option.value && option.value != '1') {
						newoptions.push(option);
					}
				});
			} else {
				item.options.map((option) => {
					if (option.value && option.value != '3') {
						newoptions.push(option);
					}
				});
			}
			item.options = newoptions;
		}
	});

	//增加超链接
	meta[proTransferHead].items = meta[proTransferHead].items.map((item, key) => {
		if (item.attrcode == 'bill_code') {
			item.render = (text, record, index) => {
				let transType = record.transi_type.value;
				return (
					<div class="simple-table-td">
						<span
							className="code-detail-link"
							onClick={() => {
								linkCard.call(this, props, record, 'pk_transasset', transType);
							}}
						>
							{record && record.bill_code && record.bill_code.value}
						</span>
					</div>
				);
			};
		}

		return item;
	});
	return meta;
}

/*2xfYlvBzgNfctrVamd18oLATkukPltP/lqqKWCwDAvihRtHNmksWzOZslYhN6jqs*/